# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.ods.mysql.work_order.work_order import jms_ods__work_order
from jms.ods.mysql.project_work_order import jms_ods__project_work_order
from jms.ods.mysql.claim_work_order import jms_ods__claim_work_order
from jms.ods.mysql.appeal_info import jms_ods__appeal_info
from jms.dim.dim_lmdm_sys_network_expand import jms_dim__dim_lmdm_sys_network_expand

jms_dwd__dwd_complaint_work_order_detail_dt = SparkSqlOperator(
    task_id='jms_dwd__dwd_complaint_work_order_detail_dt',
    task_concurrency=1,
    pool_slots=1,
    master='yarn',
    execution_timeout=timedelta(hours=1),
    email=['yushuo@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_complaint_work_order_detail_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dwd/dwd_complaint_work_order_detail_dt/execute.sql',
    driver_memory='2G' , 
    driver_cores=2 , 
    executor_cores=2 , 
    executor_memory='1G' , 
    num_executors=2 , 
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 180,  # 动态资源自动释放闲置 Executor 的超时时间(s)
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.network.timeout': 900,
          'spark.core.connection.ack.wait.timeout': 300
          },
    yarn_queue='pro',
)
jms_dwd__dwd_complaint_work_order_detail_dt << [
    jms_ods__work_order,
    jms_ods__project_work_order,
    jms_ods__claim_work_order,
    jms_ods__appeal_info,
    jms_dim__dim_lmdm_sys_network_expand,
]
